////
//// Source code recreated from a .class file by IntelliJ IDEA
//// (powered by FernFlower decompiler)
////
//
//package com.example.zqathserver.controller;
//
//import org.springframework.http.HttpStatus;
//import org.springframework.http.ResponseEntity;
//import org.springframework.web.bind.annotation.*;
//import org.springframework.web.servlet.view.RedirectView;
//
//import java.util.HashMap;
//import java.util.Map;
//
//@RestController
//@RequestMapping({"/idp1/oauth2"})
//public class ZQOAuthController {
//    public ZQOAuthController() {
//    }
//
//    @GetMapping({"/auth"})
//    public RedirectView redirect(@RequestParam(value = "redirect_uri",required = false) String redirectUri, @RequestParam(value = "processCode",required = false) String processCode, @RequestParam(value = "businessKey",required = false) String businessKey, @RequestParam(value = "navigatePath",required = false) String navigatePath) {
//        String code = "code111";
//        String targetUrl = redirectUri + "&code=" + code;
//        RedirectView redirectView = new RedirectView();
//        redirectView.setUrl(targetUrl);
//        return redirectView;
//    }
//
//    @PostMapping({"/getToken"})
//    public ResponseEntity<Object> getToken(@RequestParam(value = "client_id",required = false) String clientId, @RequestParam(value = "client_secret",required = false) String clientSecret, @RequestParam(value = "code",required = false) String code, @RequestParam(value = "grant_type",required = false,defaultValue = "authorization_code") String grantType) {
//        if (clientId == null) {
//            return this.generateErrorResponse("1001", "缺少参数client_id");
//        } else if (clientSecret == null) {
//            return this.generateErrorResponse("1008", "缺少参数client_secret");
//        } else if (code == null) {
//            return this.generateErrorResponse("1009", "缺少参数code");
//        } else if (grantType != null && grantType.equals("authorization_code")) {
//            if (!"code111".equals(code)) {
//                return this.generateErrorResponse("1014", "参数code非法");
//            } else if (!"appId111".equals(clientId)) {
//                return this.generateErrorResponse("1005", "参数client_id非法");
//            } else if (!"appSecret111".equals(clientSecret)) {
//                return this.generateErrorResponse("1012", "参数client_secret非法");
//            } else {
//                Map<String, Object> response = new HashMap();
//                response.put("access_token", "accessToken111");
//                response.put("expires_in", "1500");
//                response.put("refresh_token", "iewoer233422i34o2i34uio55iojhg6g");
//                response.put("uid", "1981");
//                return ResponseEntity.ok(response);
//            }
//        } else {
//            return this.generateErrorResponse("1010", "缺少参数grant_type");
//        }
//    }
//
//    @GetMapping({"/getUserInfo"})
//    public ResponseEntity<Object> getUserInfo(@RequestParam(value = "access_token",required = false) String accessToken, @RequestParam(value = "client_id",required = false) String clientId) {
//        if (clientId == null) {
//            return this.generateErrorResponse("1001", "缺少参数client_id");
//        } else if (accessToken == null) {
//            return this.generateErrorResponse("2001", "缺少参数access_token");
//        } else if (!"appId111".equals(clientId)) {
//            return this.generateErrorResponse("1005", "参数client_id非法");
//        } else if (!"accessToken111".equals(accessToken)) {
//            return this.generateErrorResponse("2002", "参数access_token不正确或过期");
//        } else {
//            Map<String, Object> userInfo = new HashMap();
//            userInfo.put("mail", "1234567890@qqq.com");
//            userInfo.put("spRoleList", new String[]{"300002"});
//            userInfo.put("loginName", "hyf");
//            userInfo.put("mobile", "13356707334");
//            return ResponseEntity.ok(userInfo);
//        }
//    }
//
//    private ResponseEntity<Object> generateErrorResponse(String errcode, String msg) {
//        Map<String, Object> errorResponse = new HashMap();
//        errorResponse.put("errcode", errcode);
//        errorResponse.put("msg", msg);
//        return new ResponseEntity(errorResponse, HttpStatus.BAD_REQUEST);
//    }
//
//    @GetMapping({"/test"})
//    public String parseRedirectUri(@RequestParam("redirect_uri") String redirectUri) {
//        System.out.println(redirectUri + "Yaojx'");
//        new HashMap();
//        return redirectUri;
//    }
//}
